<?php
class Default_Form_Equipment extends Zend_Form
{

    public function init()
    {
        // id
        $this->setName("equipment");

        $equipmentId = new Zend_Form_Element_Hidden('$equipmentId');
 		$equipmentId->removeDecorator('HtmlTag');
 		$equipmentId->removeDecorator('Label');

        $equipmentName = new Zend_Form_Element_Text('equipmentName');
        $equipmentName->setLabel('Tên thiết bị *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $equipmentName->setAttrib('size', 60);

        $code = new Zend_Form_Element_Text('code');
        $code->setLabel('Mã quản lý *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $code->setAttrib('size', 60);
        $code->setAttrib('readonly', 'readonly');

        /* $status = new Zend_Form_Element_Checkbox('status');
        $status->setLabel('Tình trạng'); */
        // $status = new Zend_Form_Element_Select('status');
        // $status->setLabel('Tình trạng');
        // $status->addMultiOption(0,'không hoạt động');
        // $status->addMultiOption(1,'đang hoạt động');
        // $status->setAttrib('style', 'width: 200px');

        $ip = new Zend_Form_Element_Text('ip');
        $ip->setLabel('IP Lan')->addFilter('StripTags')->addFilter('StringTrim');
        $ip->setAttrib('size', 60);

        $ipWan = new Zend_Form_Element_Text('ipWan');
        $ipWan->setLabel('IP Wan')->addFilter('StripTags')->addFilter('StringTrim');
        $ipWan->setAttrib('size', 60);

				
		// $params = new Zend_Form_Element_Text('params');
        // $params->setLabel('Danh sách dùng chung')->addFilter('StripTags')->addFilter('StringTrim');
        // $params->setAttrib('size', 60);
		
		
		// $checkGeneral = new Zend_Form_Element_Checkbox("checkGeneral");
		// $checkGeneral->setLabel('Đang Dùng Chung (Yes/No)')->addFilter('StripTags');
		$checkGeneral = new Zend_Form_Element_Select('isGeneral');
        $checkGeneral->setLabel('Đang Dùng Chung (Yes/No) *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $checkGeneral->addMultiOption(0,'No');
		$checkGeneral->addMultiOption(1,'Yes');
		
//        $info = new Zend_Form_Element_Textarea('info');
//        $info->setLabel('Thông tin thiết bị')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
//        $info->setAttrib('cols', 45)->setAttrib('rows', 6);


        $position = new Zend_Form_Element_Text('position');
        $position->setLabel('Vị trí *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $position->setAttrib('size', 60);

        $function = new Zend_Form_Element_Text('function');
        $function->setLabel('Chức năng')->addFilter('StripTags')->addFilter('StringTrim');
        $function->setAttrib('size', 60);

//        $owner = new Zend_Form_Element_Text('owner');
//        $owner->setLabel('Tài sản')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
//        $owner->setAttrib('size', 60);

//        $holders = new Zend_Form_Element_Text('holders');
//        $holders->setLabel('Người ký hợp đồng')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
//        $holders->setAttrib('size', 60);


        $endUser = new Zend_Form_Element_Text('endUser');
        $endUser->setLabel('Người sử dụng')->addFilter('StripTags')->addFilter('StringTrim');
        $endUser->setAttrib('size', 60);

//		$price = new Zend_Form_Element_Text('price');
//        $price->setLabel('Giá hiện tại')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator('Digits');
//        $price->setAttrib('size', 60);

//		$history = new Zend_Form_Element_Text('history');
//        $history->setLabel('Lịch sử')->addFilter('StripTags')->addFilter('StringTrim');
//        $history->setAttrib('size', 60);

//		$startDate = new Zend_Form_Element_Text('startDate');
//        $startDate->setLabel('Ngày bắt đầu')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
//        $startDate->setAttrib('size', 60);
//		$startDate->setAttrib('readOnly', true);

//		$duration = new Zend_Form_Element_Text('duration');
//        $duration->setLabel('Thời gian')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
//        $duration->setAttrib('size', 60);
//		$duration->setAttrib('readOnly', true);

        $note = new Zend_Form_Element_Textarea('note');
        $note->setLabel('Ghi chú')->addFilter('StripTags')->addFilter('StringTrim');
        $note->setAttrib('cols', 45)->setAttrib('rows', 6);

        $category = new Zend_Form_Element_Select('categoryId');
        $category->setLabel('Nhóm thiết bị *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $category->setAttrib('style', 'width: 200px');
      	$model_category = new Default_Model_Category();
        $categories = $model_category->fetchAll();
        foreach($categories as $c)
        	$category->addMultiOption($c->categoryId,$c->categoryName);

        $manager = new Zend_Form_Element_Select('managerId');
        $manager->setLabel('Quản lý kỹ thuật *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $manager->setAttrib('style', 'width: 200px');
        $model_user = new Default_Model_Users();
        $users = $model_user->fetchAll();
        foreach($users as $user)
        	$manager->addMultiOption($user->userId,$user->username);
        
		$params = new Zend_Form_Element_Multiselect('params');
        $params->setLabel('Danh sách công ty dùng chung (Được chọn nhiều)')->addFilter('StripTags')->addFilter('StringTrim');
		$params->addMultiOption('ssgroup' ,'ssgroup');
		$params->addMultiOption('ssgame' ,'ssgame');
		$params->addMultiOption('wingame' ,'wingame');
		$params->addMultiOption('3s' ,'3s');
        
		$borrow = new Zend_Form_Element_Select('borrow');
        $borrow->setLabel('Công ty mượn')->addFilter('StripTags')->addFilter('StringTrim');
		$borrow->addMultiOption('' ,'Vui lòng chọn');
		$borrow->addMultiOption('ssgroup' ,'ssgroup');
		$borrow->addMultiOption('ssgame' ,'ssgame');
		$borrow->addMultiOption('wingame' ,'wingame');
		$borrow->addMultiOption('3s' ,'3s');
        
        $project = new Zend_Form_Element_Multiselect('projectId');
        $project->setLabel('Dự án (Được chọn nhiều) *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $model_project = new Default_Model_Project();
        $projectData = $model_project->fetchAll();
        foreach ($projectData as $p)
        	$project->addMultiOption($p->projectId ,$p->projectName);

        $trackDate = new Zend_Form_Element_Text('trackDate');
        $trackDate->setLabel('Ngày theo dõi')->addFilter('StripTags')->addFilter('StringTrim');
        $trackDate->setAttrib('placeholder', 'mm/dd/yy');
        $trackDate->setAttrib('size', 27);
        $trackDate->setAttrib('readOnly', 'readOnly');
        
        $trackContent = new Zend_Form_Element_Textarea('trackContent');
        $trackContent->setLabel('Nội dung theo dõi')->addFilter('StripTags')->addFilter('StringTrim');
        $trackContent->setAttrib('cols', 45)->setAttrib('rows', 6);

        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id','submitbutton');
        $submit->setAttrib('class',"button medium");
        // add elements to form
        //$hash = new Zend_Form_Element_Hash('no_csrf_foo');
        //$this->addElement('hash','no_csrf_foo',array (
        //    'salt' => 'T1EJtbLm40sRWNsj'
        //));

        $this->addElements(array (
            $equipmentId, $equipmentName ,$category ,$code , $ip, $ipWan, $position, $function, $endUser, $checkGeneral, $params, $borrow, $note, $manager , $project, $trackDate, $trackContent, $submit
        ));
    }
}

